import 'package:common_utils/common_utils.dart';
import 'package:flutter/material.dart';
import 'package:flutter_shop/pages/base/base_state_less_widget.dart';
import 'package:flutter_shop/pages/cart/cart_tab_page/entity/cart_goods_data.dart';
import 'package:flutter_shop/pages/cart/order_confirm/order_confirm_presenter.dart';
import 'package:flutter_shop/res/colors.dart';
import 'package:flutter_shop/res/dimens.dart';
import 'package:flutter_shop/widget/water_click.dart';

/// Title:底部确认订单 <br/>
/// Description: <br/>
/// author:Administrator <br/>
/// date: 2020-03-09  <br/>
/// version 1.0 <br/>
class BottomConfirm extends BaseStateLessWidget<OrderConfirmPresenter> {
  final List<CartGoodsData> list;

  BottomConfirm({this.list});

  @override
  Widget build(BuildContext context) {
    //计算小计价格
    double subtotal = 0;
    list.forEach((item) {
      double price = NumUtil.multiply(item.price, item.count);
      subtotal = NumUtil.add(subtotal, price);
    });

    return Container(
      height: 50,
      color: Colors.black87,
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceAround,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: <Widget>[
          Expanded(
            child: Container(
              padding: EdgeInsets.only(left: 15),
              child: Text(
                "¥$subtotal",
                style: TextStyle(fontSize: CommonDimens.font_size_xlarge, color: Colors.white),
              ),
            ),
          ),
          WaterClick(
            width: 100,
            height: double.infinity,
            fillColor: CommonColors.green,
            onPressed: () {
              mPresenter.callPay(list);
              mPresenter.updateStateWidget();
            },
            child: Text(
              "确认支付",
              style: TextStyle(fontSize: CommonDimens.font_size_middle, color: Colors.white),
            ),
          )
        ],
      ),
    );
  }
}
